package com.whnk.web.controller.rtms;

import java.util.ArrayList;
import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.whnk.common.annotation.Log;
import com.whnk.common.base.AjaxResult;
import com.whnk.common.enums.BusinessType;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.rtms.domain.VrsnAncCfgMgt;
import com.whnk.rtms.domain.VrsnAncCfgMgtVo;
import com.whnk.rtms.service.IVrsnAncCfgMgtService;

/**
 * 版本发布配置管理 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-03-29
 */
@Controller
@RequestMapping("/rtms/vrsnAncCfgMgt")
public class VrsnAncCfgMgtController extends BaseController
{
    private String prefix = "rtms/vrsnAncCfgMgt";
	
	@Autowired
	private IVrsnAncCfgMgtService vrsnAncCfgMgtService;
	
	@RequiresPermissions("rtms:vrsnAncCfgMgt:view")
	@GetMapping()
	public String vrsnAncCfgMgt()
	{
	    return prefix + "/vrsnAncCfgMgt";
	}
	
	/**
	 * 查询版本发布配置管理列表
	 */
	@RequiresPermissions("rtms:vrsnAncCfgMgt:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(VrsnAncCfgMgt ancCfgMgt)
	{
		startPage();
        List<VrsnAncCfgMgtVo> list = vrsnAncCfgMgtService.selectVrsnAncCfgMgtList(ancCfgMgt);
		return getDataTable(list);
	}
	
	/**
	 * 新增版本发布配置管理
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存版本发布配置管理
	 */
	@RequiresPermissions("rtms:vrsnAncCfgMgt:add")
	@Log(title = "版本发布配置管理", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(VrsnAncCfgMgtVo ancCfgMgtVo)
	{
		return toAjax(vrsnAncCfgMgtService.insertVrsnAncCfgMgt(ancCfgMgtVo));
	}

	/**
	 * 修改版本发布配置管理
	 */
	@GetMapping("/edit/{lgcPk}")
	public String edit(@PathVariable("lgcPk") String lgcPk, ModelMap mmap)
	{
		VrsnAncCfgMgtVo vrsnAncCfgMgtVo = vrsnAncCfgMgtService.selectVrsnAncCfgMgtById(lgcPk);
		mmap.put("vrsnAncCfgMgtVo", vrsnAncCfgMgtVo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存版本发布配置管理
	 */
	@RequiresPermissions("rtms:vrsnAncCfgMgt:edit")
	@Log(title = "版本发布配置管理", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(VrsnAncCfgMgtVo ancCfgMgtVo)
	{		
		return toAjax(vrsnAncCfgMgtService.updateVrsnAncCfgMgt(ancCfgMgtVo));
	}
	
	/**
	 * 删除版本发布配置管理
	 */
	@RequiresPermissions("rtms:vrsnAncCfgMgt:remove")
	@Log(title = "版本发布配置管理", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(vrsnAncCfgMgtService.deleteVrsnAncCfgMgtByIds(ids));
	}
}
